FROM php:7.3-fpm

RUN apt-get update

RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev libcurl4-gnutls-dev git zip unzip libsodium-dev librabbitmq-dev

RUN docker-php-ext-install -j$(nproc) iconv \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install mbstring mysqli pdo pdo_mysql curl \
    && docker-php-ext-install sodium \
    && pecl install amqp \
    && docker-php-ext-enable amqp \
    && curl http://pecl.php.net/get/redis-4.2.0.tgz > /tmp/redis-4.2.0.tgz \
    && sh -c '/bin/echo -e "\n\n" | pecl install /tmp/redis-4.2.0.tgz' \
    && rm -f /tmp/redis-4.2.0.tgz \
    && docker-php-ext-enable redis \
    && cd /tmp \
    && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php composer-setup.php \
    && mv composer.phar /usr/local/bin/composer \
    && cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini \
    && sed -i "s/;date.timezone =/date.timezone = PRC/g" /usr/local/etc/php/php.ini \
    && ln -sf /usr/share/zoneinfo/Asia/Shanghai    /etc/localtime \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/


WORKDIR /data/kk-api


RUN echo "#!/usr/bin/env bash" > /entrypoint.sh \
	&& echo "php-fpm > /dev/null" >> /entrypoint.sh \
	&& chmod +x /entrypoint.sh


ENTRYPOINT [ "/entrypoint.sh"]